package com.slz3.business.module.memberManagement.memRecord.service;

import com.slz3.business.frame.module.Repositorys;
import com.slz3.business.module.memberManagement.memRecord.domain.MemRecord;
import com.slz3.business.module.memberManagement.memRecord.domain.MemRecordFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Slf4j
@Service
public class MemRecordTransactionalServiceImpl implements MemRecordTransactionalService {

    @Override
    public MemRecord modify(MemRecord memRecordNew) {
        Repositorys.memRecord.test();
        Repositorys.memRecord.save(MemRecordFactory.initBaseFields());
        System.err.println(1/0);
        memRecordNew.setLastModifyTime(LocalDateTime.now());
        return Repositorys.memRecord.saveAndFlush(memRecordNew);
    }

    @Override
    public List<MemRecord> batchModify(List<MemRecord> memRecordList) {
        return Repositorys.memRecord.saveAll(memRecordList);
    }
}
